{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "949ce7f3",
   "metadata": {},
   "source": [
    "------\n",
    "* 2022-8-30\n",
    "* python学习第二周\n",
    "* 记录人:梁颖\n",
    "------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ae062e6f",
   "metadata": {},
   "source": [
    "# 本周学习内容\n",
    "## 1.Head First Python P4\n",
    "> 一定要按照规格书写以下代码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "5e6db2ea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "42\n",
      "现在分钟时间为偶数\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "# 本项目用到了时间模块\n",
    "#print(datetime.datetime.today().microsecond)\n",
    "\n",
    "# odds 是一个变量，后面可以直接使用\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "right_this_minute = datetime.datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在是分钟为基数的时间\")\n",
    "else:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在分钟时间为偶数\")\n",
    "\n",
    "#print(datetime.datetime.today().microsecond)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e312cfd",
   "metadata": {},
   "source": [
    "### 判断当天是一周中的星期几，如果是星期二，打印Python课表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "b44ce626",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "b256d4c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "ec922061",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "今天有python课，时间为：下午2:30-4:50\n"
     ]
    }
   ],
   "source": [
    "# tm_wday: 0-6 0 是星期一\n",
    "今天 = time.localtime().tm_wday\n",
    "\n",
    "if 今天 == 1:\n",
    "    print(\"今天有python课，时间为：下午2:30-4:50\")\n",
    "else:\n",
    "    print(\"今天没有python课,哈哈哈哈哈哈哈\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b18d2c1a",
   "metadata": {},
   "source": [
    "### 判断当天是一周中的星期几，如果是星期二，看下现在几点了，是python课ing吗？如果是，请打印Python课表 （课本P18）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "91a281f4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "b4c0374a",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'time.struct_time' object has no attribute 'tm_minute'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Input \u001b[0;32mIn [35]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m time\u001b[38;5;241m.\u001b[39mlocaltime()\u001b[38;5;241m.\u001b[39mtm_hour \u001b[38;5;66;03m# 是不是在 14-16之间 如果是14 再看tm_minute 是不是在0-30 如果是16 再看tm.minute 是不是在50以上\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mtime\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlocaltime\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtm_minute\u001b[49m\n",
      "\u001b[0;31mAttributeError\u001b[0m: 'time.struct_time' object has no attribute 'tm_minute'"
     ]
    }
   ],
   "source": [
    "time.localtime().tm_hour # 是不是在 14-16之间 如果是14 再看tm_minute 是不是在0-30 如果是16 再看tm.minute 是不是在50以上\n",
    "time.localtime().tm_minute"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0d45e309",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'datetime' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[0;32mIn [1]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m help(\u001b[43mdatetime\u001b[49m)\n",
      "\u001b[0;31mNameError\u001b[0m: name 'datetime' is not defined"
     ]
    }
   ],
   "source": [
    "help(datetime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "933d43a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 9, 6)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime\n",
    "datetime.date.today()\n",
    "#datetime 可以获取年月日，但不能获取到星期几"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "abefd351",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "f952c728",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Work, work, work.\n"
     ]
    }
   ],
   "source": [
    "# 创建today变量（模块获取今天是星期几？）\n",
    "# 知识点： 1. 先创建变量，才能进行判断\n",
    "#         2. if语句 观察\n",
    "today = \"Monday\"\n",
    "condition = \"Headache\"\n",
    "\n",
    "if today == \"Saturday\":\n",
    "    print(\"超开心\") # if条件判断块\n",
    "elif today == \"Sunday\":\n",
    "    if condition == \"Headache\":\n",
    "        print(\"Recover, then rest.\") \n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"Work, work, work.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a250d2c",
   "metadata": {},
   "source": [
    "## 判断当前是一周中的星期几，如果是星期二，看下现在几点了，是python课ing吗？然后打印Python课表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "f09cf060",
   "metadata": {},
   "outputs": [],
   "source": [
    "# wday = 0, 1, 2, 3, 4, 5, 6  分别指周一到周日\n",
    "import time\n",
    "\n",
    "wday = time.localtime().tm_wday\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "252c99a5",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_hour = time.localtime().tm_hour"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "178cf75d",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_min = time.localtime().tm_min"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "dec286f7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "正在上Python课,妈呀，还在上，才两点\n"
     ]
    }
   ],
   "source": [
    "if wday != 1: # 判断是否是周二\n",
    "    print(\"今天没有Python课\")\n",
    "elif time_hour == 12 and time_min > 50:\n",
    "    print(\"正在上Python课,刚上课\")\n",
    "elif time_hour == 13:\n",
    "    print(\"正在上Python课,大概第二节了\")\n",
    "elif time_hour == 14:\n",
    "    print(\"正在上Python课,妈呀，还在上，才两点\")\n",
    "elif time_hour == 15:\n",
    "    print(\"正在上Python课,坚持一下，快下课了！\")\n",
    "elif time_hour == 16 and time_min < 50:\n",
    "    print(\"正在上Python课,最后一节课，快下课啦\")\n",
    "else:\n",
    "    print(\"今天有Python课,时间是下午12:50-16:50\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "624246e7",
   "metadata": {},
   "source": [
    "## 2.1 模块--[标准库](https://docs.python.org/3/library/index.html)\n",
    "\n",
    "* 标准库是Python开发团队为满足Python用户日常需求而写好的一些模块,可以直接使用: import模块名称\n",
    "\n",
    "> 1.sys模块  \n",
    "> 2.os模块  \n",
    "> 3.datetime模块\n",
    "\n",
    "## 2.2 模块--开源模块(pypi.org)\n",
    "\n",
    "## 2.3 自定义模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "901c34ba",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "b29bf90e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "265f3249",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'3.9.12 (main, Apr  5 2022, 01:53:17) \\n[Clang 12.0.0 ]'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sys.version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "39cde446",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "de2edc6c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/Users/kristenleung/Python'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "f78e2e6e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "b24f1a13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 8, 30)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "56456752",
   "metadata": {},
   "source": [
    "# 认识下 time模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "0f2310d7",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "d8247b28",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=8, tm_mday=30, tm_hour=14, tm_min=31, tm_sec=29, tm_wday=1, tm_yday=242, tm_isdst=0)"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "ad5c3a13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1661841124.469722"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time() # 时间戳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "b58e9482",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "52.696637525399105"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()/60/60/24/365"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "18bc50a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1970"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2022-52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "20915075",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=8, tm_mday=30, tm_hour=6, tm_min=33, tm_sec=23, tm_wday=1, tm_yday=242, tm_isdst=0)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b654140e",
   "metadata": {},
   "source": [
    "## help"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "04941e35",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in module time:\n",
      "\n",
      "NAME\n",
      "    time - This module provides various functions to manipulate time values.\n",
      "\n",
      "DESCRIPTION\n",
      "    There are two standard representations of time.  One is the number\n",
      "    of seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer\n",
      "    or a floating point number (to represent fractions of seconds).\n",
      "    The Epoch is system-defined; on Unix, it is generally January 1st, 1970.\n",
      "    The actual value can be retrieved by calling gmtime(0).\n",
      "    \n",
      "    The other representation is a tuple of 9 integers giving local time.\n",
      "    The tuple items are:\n",
      "      year (including century, e.g. 1998)\n",
      "      month (1-12)\n",
      "      day (1-31)\n",
      "      hours (0-23)\n",
      "      minutes (0-59)\n",
      "      seconds (0-59)\n",
      "      weekday (0-6, Monday is 0)\n",
      "      Julian day (day in the year, 1-366)\n",
      "      DST (Daylight Savings Time) flag (-1, 0 or 1)\n",
      "    If the DST flag is 0, the time is given in the regular time zone;\n",
      "    if it is 1, the time is given in the DST time zone;\n",
      "    if it is -1, mktime() should guess based on the date and time.\n",
      "\n",
      "CLASSES\n",
      "    builtins.tuple(builtins.object)\n",
      "        struct_time\n",
      "    \n",
      "    class struct_time(builtins.tuple)\n",
      "     |  struct_time(iterable=(), /)\n",
      "     |  \n",
      "     |  The time value as returned by gmtime(), localtime(), and strptime(), and\n",
      "     |  accepted by asctime(), mktime() and strftime().  May be considered as a\n",
      "     |  sequence of 9 integers.\n",
      "     |  \n",
      "     |  Note that several fields' values are not the same as those defined by\n",
      "     |  the C language standard for struct tm.  For example, the value of the\n",
      "     |  field tm_year is the actual year, not year - 1900.  See individual\n",
      "     |  fields' descriptions for details.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      struct_time\n",
      "     |      builtins.tuple\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  tm_gmtoff\n",
      "     |      offset from UTC in seconds\n",
      "     |  \n",
      "     |  tm_hour\n",
      "     |      hours, range [0, 23]\n",
      "     |  \n",
      "     |  tm_isdst\n",
      "     |      1 if summer time is in effect, 0 if not, and -1 if unknown\n",
      "     |  \n",
      "     |  tm_mday\n",
      "     |      day of month, range [1, 31]\n",
      "     |  \n",
      "     |  tm_min\n",
      "     |      minutes, range [0, 59]\n",
      "     |  \n",
      "     |  tm_mon\n",
      "     |      month of year, range [1, 12]\n",
      "     |  \n",
      "     |  tm_sec\n",
      "     |      seconds, range [0, 61])\n",
      "     |  \n",
      "     |  tm_wday\n",
      "     |      day of week, range [0, 6], Monday is 0\n",
      "     |  \n",
      "     |  tm_yday\n",
      "     |      day of year, range [1, 366]\n",
      "     |  \n",
      "     |  tm_year\n",
      "     |      year, for example, 1993\n",
      "     |  \n",
      "     |  tm_zone\n",
      "     |      abbreviation of timezone name\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  n_fields = 11\n",
      "     |  \n",
      "     |  n_sequence_fields = 9\n",
      "     |  \n",
      "     |  n_unnamed_fields = 0\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from builtins.tuple:\n",
      "     |  \n",
      "     |  __add__(self, value, /)\n",
      "     |      Return self+value.\n",
      "     |  \n",
      "     |  __contains__(self, key, /)\n",
      "     |      Return key in self.\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __getitem__(self, key, /)\n",
      "     |      Return self[key].\n",
      "     |  \n",
      "     |  __getnewargs__(self, /)\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __iter__(self, /)\n",
      "     |      Implement iter(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __len__(self, /)\n",
      "     |      Return len(self).\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __mul__(self, value, /)\n",
      "     |      Return self*value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __rmul__(self, value, /)\n",
      "     |      Return value*self.\n",
      "     |  \n",
      "     |  count(self, value, /)\n",
      "     |      Return number of occurrences of value.\n",
      "     |  \n",
      "     |  index(self, value, start=0, stop=9223372036854775807, /)\n",
      "     |      Return first index of value.\n",
      "     |      \n",
      "     |      Raises ValueError if the value is not present.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods inherited from builtins.tuple:\n",
      "     |  \n",
      "     |  __class_getitem__(...) from builtins.type\n",
      "     |      See PEP 585\n",
      "\n",
      "FUNCTIONS\n",
      "    asctime(...)\n",
      "        asctime([tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\n",
      "        When the time tuple is not present, current time as returned by localtime()\n",
      "        is used.\n",
      "    \n",
      "    ctime(...)\n",
      "        ctime(seconds) -> string\n",
      "        \n",
      "        Convert a time in seconds since the Epoch to a string in local time.\n",
      "        This is equivalent to asctime(localtime(seconds)). When the time tuple is\n",
      "        not present, current time as returned by localtime() is used.\n",
      "    \n",
      "    get_clock_info(...)\n",
      "        get_clock_info(name: str) -> dict\n",
      "        \n",
      "        Get information of the specified clock.\n",
      "    \n",
      "    gmtime(...)\n",
      "        gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n",
      "                               tm_sec, tm_wday, tm_yday, tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n",
      "        GMT).  When 'seconds' is not passed in, convert the current time instead.\n",
      "        \n",
      "        If the platform supports the tm_gmtoff and tm_zone, they are available as\n",
      "        attributes only.\n",
      "    \n",
      "    localtime(...)\n",
      "        localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,\n",
      "                                  tm_sec,tm_wday,tm_yday,tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing local time.\n",
      "        When 'seconds' is not passed in, convert the current time instead.\n",
      "    \n",
      "    mktime(...)\n",
      "        mktime(tuple) -> floating point number\n",
      "        \n",
      "        Convert a time tuple in local time to seconds since the Epoch.\n",
      "        Note that mktime(gmtime(0)) will not generally return zero for most\n",
      "        time zones; instead the returned value will either be equal to that\n",
      "        of the timezone or altzone attributes on the time module.\n",
      "    \n",
      "    monotonic(...)\n",
      "        monotonic() -> float\n",
      "        \n",
      "        Monotonic clock, cannot go backward.\n",
      "    \n",
      "    monotonic_ns(...)\n",
      "        monotonic_ns() -> int\n",
      "        \n",
      "        Monotonic clock, cannot go backward, as nanoseconds.\n",
      "    \n",
      "    perf_counter(...)\n",
      "        perf_counter() -> float\n",
      "        \n",
      "        Performance counter for benchmarking.\n",
      "    \n",
      "    perf_counter_ns(...)\n",
      "        perf_counter_ns() -> int\n",
      "        \n",
      "        Performance counter for benchmarking as nanoseconds.\n",
      "    \n",
      "    process_time(...)\n",
      "        process_time() -> float\n",
      "        \n",
      "        Process time for profiling: sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    process_time_ns(...)\n",
      "        process_time() -> int\n",
      "        \n",
      "        Process time for profiling as nanoseconds:\n",
      "        sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    sleep(...)\n",
      "        sleep(seconds)\n",
      "        \n",
      "        Delay execution for a given number of seconds.  The argument may be\n",
      "        a floating point number for subsecond precision.\n",
      "    \n",
      "    strftime(...)\n",
      "        strftime(format[, tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string according to a format specification.\n",
      "        See the library reference manual for formatting codes. When the time tuple\n",
      "        is not present, current time as returned by localtime() is used.\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    strptime(...)\n",
      "        strptime(string, format) -> struct_time\n",
      "        \n",
      "        Parse a string to a time tuple according to a format specification.\n",
      "        See the library reference manual for formatting codes (same as\n",
      "        strftime()).\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    time(...)\n",
      "        time() -> floating point number\n",
      "        \n",
      "        Return the current time in seconds since the Epoch.\n",
      "        Fractions of a second may be present if the system clock provides them.\n",
      "    \n",
      "    time_ns(...)\n",
      "        time_ns() -> int\n",
      "        \n",
      "        Return the current time in nanoseconds since the Epoch.\n",
      "    \n",
      "    tzset(...)\n",
      "        tzset()\n",
      "        \n",
      "        Initialize, or reinitialize, the local timezone to the value stored in\n",
      "        os.environ['TZ']. The TZ environment variable should be specified in\n",
      "        standard Unix timezone format as documented in the tzset man page\n",
      "        (eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently\n",
      "        fall back to UTC. If the TZ environment variable is not set, the local\n",
      "        timezone is set to the systems best guess of wallclock time.\n",
      "        Changing the TZ environment variable without calling tzset *may* change\n",
      "        the local timezone used by methods such as localtime, but this behaviour\n",
      "        should not be relied on.\n",
      "\n",
      "DATA\n",
      "    altzone = -28800\n",
      "    daylight = 0\n",
      "    timezone = -28800\n",
      "    tzname = ('CST', 'CST')\n",
      "\n",
      "FILE\n",
      "    (built-in)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "14de0830",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'time' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[0;32mIn [8]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mtime\u001b[49m\u001b[38;5;241m.\u001b[39masctime(time\u001b[38;5;241m.\u001b[39mlocaltime())\n",
      "\u001b[0;31mNameError\u001b[0m: name 'time' is not defined"
     ]
    }
   ],
   "source": [
    "time.asctime(time.localtime())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb639887",
   "metadata": {},
   "source": [
    "## 3.赋值\n",
    "## 4.变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "871bcf75",
   "metadata": {},
   "outputs": [],
   "source": [
    "wait_time = 26\n",
    "WaitTime = 34\n",
    "\n",
    "gf_of_liu = \"Lucy\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "fa6ba47f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "26"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wait_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "4005ed9c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "int"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(wait_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "b4def5e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(gf_of_liu)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "fca1c3fb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "34"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "WaitTime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "fed18a7b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Lucy'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gf_of_liu"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "30a693f3",
   "metadata": {},
   "source": [
    "# 4. for循环和range方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "031b067c",
   "metadata": {},
   "source": [
    "### 用例1 循环迭代数字变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "065beaaa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# item 循环遍历\n",
    "for i in [1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "0126f3f7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2100001\n",
      "2100002\n",
      "2100003\n"
     ]
    }
   ],
   "source": [
    "for item in [1,2,3]:\n",
    "    print(item+2100000)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "13fe9265",
   "metadata": {},
   "source": [
    "### 用例2 循环迭代字符串变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "07a3b5ea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H\n",
      "i\n",
      "!\n"
     ]
    }
   ],
   "source": [
    "for ch in \"Hi!\":\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9aae765f",
   "metadata": {},
   "source": [
    "### 用例3 迭代指定的次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "cd9a31d2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Head First Rocks!\n",
      "Head First Rocks!\n",
      "Head First Rocks!\n",
      "Head First Rocks!\n",
      "Head First Rocks!\n"
     ]
    }
   ],
   "source": [
    "for num in range(5):\n",
    "    print(\"Head First Rocks!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "6438b1c5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range()自动生成想要的数值，可以控制for循环的次数，一个值，就是从0开始几个数\n",
    "for num in range(5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "80a035cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range()自动生成想要的数值，可以控制for循环的次数，两个值，从小数2开始，大数-小数的个数\n",
    "for num in range(2,5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "a9339d34",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "3\n",
      "6\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "# 三个值，第三个值觉得step步长\n",
    "for num in range(0,10,3):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "595288fa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/ztb/index0.htm\n",
      "https://www.nfu.edu.cn/ztb/index1.htm\n",
      "https://www.nfu.edu.cn/ztb/index2.htm\n",
      "https://www.nfu.edu.cn/ztb/index3.htm\n",
      "https://www.nfu.edu.cn/ztb/index4.htm\n",
      "https://www.nfu.edu.cn/ztb/index5.htm\n",
      "https://www.nfu.edu.cn/ztb/index6.htm\n",
      "https://www.nfu.edu.cn/ztb/index7.htm\n",
      "https://www.nfu.edu.cn/ztb/index8.htm\n",
      "https://www.nfu.edu.cn/ztb/index9.htm\n",
      "https://www.nfu.edu.cn/ztb/index10.htm\n",
      "https://www.nfu.edu.cn/ztb/index11.htm\n",
      "https://www.nfu.edu.cn/ztb/index12.htm\n",
      "https://www.nfu.edu.cn/ztb/index13.htm\n",
      "https://www.nfu.edu.cn/ztb/index14.htm\n",
      "https://www.nfu.edu.cn/ztb/index15.htm\n",
      "https://www.nfu.edu.cn/ztb/index16.htm\n",
      "https://www.nfu.edu.cn/ztb/index17.htm\n",
      "https://www.nfu.edu.cn/ztb/index18.htm\n",
      "https://www.nfu.edu.cn/ztb/index19.htm\n",
      "https://www.nfu.edu.cn/ztb/index20.htm\n",
      "https://www.nfu.edu.cn/ztb/index21.htm\n",
      "https://www.nfu.edu.cn/ztb/index22.htm\n",
      "https://www.nfu.edu.cn/ztb/index23.htm\n",
      "https://www.nfu.edu.cn/ztb/index24.htm\n",
      "https://www.nfu.edu.cn/ztb/index25.htm\n",
      "https://www.nfu.edu.cn/ztb/index26.htm\n"
     ]
    }
   ],
   "source": [
    "# for循环遍历案例:某学校新闻网站数部URL队列获取\n",
    "\n",
    "# 中大南方-招投标- https://www. nfu.edu.cn/ztb/index.htm\n",
    "\n",
    "中大南方_招投标 = \"https://www.nfu.edu.cn/ztb/index.htm\" \n",
    "for page in range(27):\n",
    "    print(\"https://www.nfu.edu.cn/ztb/index\" + str(page) + \".htm\" )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ae896ffa",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
